<!DOCTYPE html>
<html lang=zh>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000">
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top">
  
  
  <title>Hexo+Github免费搭建个人静态博客 | 王竹兴 | Blob</title>
  <meta name="description" content="概要: Hexo是一个快速、简洁且高效的静态博客框架，Hexo使用 Markdown（或其它渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页。可以将本地的网页发布到Github page（国外访问速度快）或Coding page（国内访问速度快）上，这样就能通过互联网访问博客网站了，而且是免费的。也可以再购买一个独立域名，绑定解析到Github page空间地址和Coding page">
<meta name="keywords" content="Hexo">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo+Github免费搭建个人静态博客">
<meta property="og:url" content="http://zhulao.gitee.io/blog/2019/02/19/Hexo-Github免费搭建个人静态博客/index.html">
<meta property="og:site_name" content="王竹兴 | Blog">
<meta property="og:description" content="概要: Hexo是一个快速、简洁且高效的静态博客框架，Hexo使用 Markdown（或其它渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页。可以将本地的网页发布到Github page（国外访问速度快）或Coding page（国内访问速度快）上，这样就能通过互联网访问博客网站了，而且是免费的。也可以再购买一个独立域名，绑定解析到Github page空间地址和Coding page">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnjnv8wuj21ci0oijx5.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnn0grfij21dc0m00x2.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnrp3fz0j21du13k7e6.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnse6mr5j212c02cmx8.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnvwsv5rj21dc0xcjze.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnxgf5j5j21cw0a6mz4.jpg">
<meta property="og:updated_time" content="2019-05-25T08:08:58.106Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo+Github免费搭建个人静态博客">
<meta name="twitter:description" content="概要: Hexo是一个快速、简洁且高效的静态博客框架，Hexo使用 Markdown（或其它渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页。可以将本地的网页发布到Github page（国外访问速度快）或Coding page（国内访问速度快）上，这样就能通过互联网访问博客网站了，而且是免费的。也可以再购买一个独立域名，绑定解析到Github page空间地址和Coding page">
<meta name="twitter:image" content="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnjnv8wuj21ci0oijx5.jpg">
  <!-- Canonical links -->
  <link rel="canonical" href="http://zhulao.gitee.io/blog/2019/02/19/Hexo-Github免费搭建个人静态博客/index.html">
  
    <link rel="alternate" href="/atom.xml" title="王竹兴 | Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png" type="image/x-icon">
  
  <link rel="stylesheet" href="/blog/css/style.css">
  
  
  
  
</head>


<body class="main-center" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="https://github.com/wzx3" target="_blank">
          <img class="img-circle img-rotate" src="/blog/images/avatar.jpeg" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">王竹兴</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md"></h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> XiaMen, China</small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="搜索">
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="想要查找什么..." x-webkit-speech>
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav menu-highlight">
        
        
        <li class="menu-item menu-item-home">
          <a href="/blog/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">首页</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">归档</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">分类</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">标签</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-repository">
          <a href="/blog/repository">
            
            <i class="icon icon-project"></i>
            
            <span class="menu-title">项目</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about">
            
            <i class="icon icon-cup-fill"></i>
            
            <span class="menu-title">关于</span>
          </a>
        </li>
        
      </ul>
      
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/wzx3" target="_blank" title="Github" data-toggle="tooltip" data-placement="top"><i class="icon icon-github"></i></a></li>
        
        <li><a href="/blog/atom.xml" target="_blank" title="Rss" data-toggle="tooltip" data-placement="top"><i class="icon icon-rss"></i></a></li>
        
    </ul>

    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">公告</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>人生最快意的事情之一, 就是你比别人牛逼, 然后静静的看别人在你面前装逼。</p>
            </div>
        </div>
    </div>
</div>

    
      
  <div class="widget">
    <h3 class="widget-title">分类</h3>
    <div class="widget-body">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/便签/">便签</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/教程/">教程</a><span class="category-list-count">22</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/游记/">游记</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/随笔/">随笔</a><span class="category-list-count">6</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">标签云</h3>
    <div class="widget-body tagcloud">
      <a href="/blog/tags/DL/" style="font-size: 13.25px;">DL</a> <a href="/blog/tags/Debug/" style="font-size: 13.5px;">Debug</a> <a href="/blog/tags/Doc/" style="font-size: 13px;">Doc</a> <a href="/blog/tags/Hexo/" style="font-size: 13.25px;">Hexo</a> <a href="/blog/tags/Links/" style="font-size: 13px;">Links</a> <a href="/blog/tags/Linux/" style="font-size: 13.25px;">Linux</a> <a href="/blog/tags/Mac/" style="font-size: 13px;">Mac</a> <a href="/blog/tags/bazel/" style="font-size: 13px;">bazel</a> <a href="/blog/tags/c-c/" style="font-size: 13.75px;">c/c++</a> <a href="/blog/tags/git/" style="font-size: 13px;">git</a> <a href="/blog/tags/rst/" style="font-size: 13px;">rst</a> <a href="/blog/tags/scripts/" style="font-size: 13.75px;">scripts</a> <a href="/blog/tags/ssh/" style="font-size: 13px;">ssh</a> <a href="/blog/tags/国学经典/" style="font-size: 13px;">国学经典</a> <a href="/blog/tags/持续集成/" style="font-size: 13.25px;">持续集成</a> <a href="/blog/tags/科幻小说/" style="font-size: 14px;">科幻小说</a>
    </div>
  </div>

    
      
  <div class="widget">
    <h3 class="widget-title">归档</h3>
    <div class="widget-body">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2019/05/">五月 2019</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2019/04/">四月 2019</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2019/03/">三月 2019</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2019/02/">二月 2019</a><span class="archive-list-count">10</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget-body">
      <ul class="recent-post-list list-unstyled no-thumbnail">
        
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/blog/categories/随笔/">随笔</a>
              </p>
              <p class="item-title">
                <a href="/blog/2019/05/26/读论语/" class="title">读论语</a>
              </p>
              <p class="item-date">
                <time datetime="2019-05-26T01:45:07.000Z" itemprop="datePublished">2019-05-26</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/blog/categories/随笔/">随笔</a>
              </p>
              <p class="item-title">
                <a href="/blog/2019/05/20/读变型战争/" class="title">读变型战争</a>
              </p>
              <p class="item-date">
                <time datetime="2019-05-20T15:51:57.000Z" itemprop="datePublished">2019-05-20</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/blog/categories/随笔/">随笔</a>
              </p>
              <p class="item-title">
                <a href="/blog/2019/05/20/读星际远征/" class="title">读黑客横行</a>
              </p>
              <p class="item-date">
                <time datetime="2019-05-20T15:40:09.000Z" itemprop="datePublished">2019-05-20</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/blog/categories/教程/">教程</a>
              </p>
              <p class="item-title">
                <a href="/blog/2019/05/15/代码格式化工具-clang-format/" class="title">代码格式化工具:clang-format</a>
              </p>
              <p class="item-date">
                <time datetime="2019-05-15T14:39:51.000Z" itemprop="datePublished">2019-05-15</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/blog/categories/教程/">教程</a>
              </p>
              <p class="item-title">
                <a href="/blog/2019/05/12/Linux-疑难杂症/" class="title">Linux 疑难杂症</a>
              </p>
              <p class="item-date">
                <time datetime="2019-05-12T02:50:29.000Z" itemprop="datePublished">2019-05-12</time>
              </p>
            </div>
          </li>
          
      </ul>
    </div>
  </div>
  

    
  </div>
</aside>

  
  
<aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    <nav id="toc" class="article-toc">
      <h3 class="toc-title">文章目录</h3>
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#搭建hexo环境"><span class="toc-number">1.</span> <span class="toc-text"> 搭建Hexo环境</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#安装-npm"><span class="toc-number">1.1.</span> <span class="toc-text"> 安装 npm</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#安装-hexo"><span class="toc-number">1.2.</span> <span class="toc-text"> 安装 hexo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#配置环境"><span class="toc-number">1.3.</span> <span class="toc-text"> 配置环境</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#hexo-常用的命令"><span class="toc-number">1.4.</span> <span class="toc-text"> hexo 常用的命令</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#部署github仓库"><span class="toc-number">2.</span> <span class="toc-text"> 部署Github仓库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#博客主题配置"><span class="toc-number">3.</span> <span class="toc-text"> 博客主题配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#在博客目录下-拉取主题git"><span class="toc-number">3.1.</span> <span class="toc-text"> 在博客目录下, 拉取主题git</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#修改主题名"><span class="toc-number">3.2.</span> <span class="toc-text"> 修改主题名</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#主题生效"><span class="toc-number">3.3.</span> <span class="toc-text"> 主题生效</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#maupassant-hexo-自定义配置"><span class="toc-number">3.4.</span> <span class="toc-text"> maupassant-hexo 自定义配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#迁移博客部署"><span class="toc-number">4.</span> <span class="toc-text"> 迁移博客部署</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#博文撰写相关"><span class="toc-number">5.</span> <span class="toc-text"> 博文撰写相关</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#front-matter"><span class="toc-number">5.1.</span> <span class="toc-text"> Front-matter</span></a></li></ol></li></ol>
    </nav>
  </div>
</aside>

<main class="main" role="main">
  <div class="content">
  <article id="post-Hexo-Github免费搭建个人静态博客" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      
        
  
    <h1 class="article-title" itemprop="name">
      Hexo+Github免费搭建个人静态博客
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/blog/2019/02/19/Hexo-Github免费搭建个人静态博客/" class="article-date">
	  <time datetime="2019-02-19T05:34:14.000Z" itemprop="datePublished">2019-02-19</time>
	</a>
</span>
        
  <span class="article-category">
    <i class="icon icon-folder"></i>
    <a class="article-category-link" href="/blog/categories/教程/">教程</a>
  </span>

        
  <span class="article-tag">
    <i class="icon icon-tags"></i>
	<a class="article-tag-link" href="/blog/tags/Hexo/">Hexo</a>
  </span>


        
	<span class="article-read hidden-xs">
	    <i class="icon icon-eye-fill" aria-hidden="true"></i>
	    <span id="busuanzi_container_page_pv">
			<span id="busuanzi_value_page_pv">0</span>
		</span>
	</span>


        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/blog/2019/02/19/Hexo-Github免费搭建个人静态博客/#comments" class="article-comment-link">评论</a></span>
        
	
		<span class="post-wordcount hidden-xs" itemprop="wordCount">字数统计: 1,596(字)</span>
	
	
		<span class="post-readcount hidden-xs" itemprop="timeRequired">阅读时长: 7(分)</span>
	

      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      
        <p><strong>概要</strong>:</p>
<p>Hexo是一个快速、简洁且高效的静态博客框架，Hexo使用 Markdown（或其它渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页。可以将本地的网页发布到Github page（国外访问速度快）或Coding page（国内访问速度快）上，这样就能通过互联网访问博客网站了，而且是免费的。也可以再购买一个独立域名，绑定解析到Github page空间地址和Coding page空间地址后，就可以用你的特色域名访问博客系统了。</p>
<p><a href="https://www.jianshu.com/p/1519f22aff24" target="_blank" rel="noopener">参考链接</a></p>
<h2 id="搭建hexo环境"><a class="markdownIt-Anchor" href="#搭建hexo环境"></a> 搭建Hexo环境</h2>
<h3 id="安装-npm"><a class="markdownIt-Anchor" href="#安装-npm"></a> 安装 <strong>npm</strong></h3>
<p>NPM的全称是Node Package Manager ，是一个NodeJS包管理和分发工具，已经成为了非官方的发布Node模块（包）的<a href="http://baike.baidu.com/view/8079.htm" target="_blank" rel="noopener">标准</a>。</p>
<p>推荐<a href="https://nodejs.org/en/#download" target="_blank" rel="noopener">官网</a>下载。</p>
<p>安装完node后建议设置<a href="http://npm.taobao.org/" target="_blank" rel="noopener">npm淘宝镜像</a>以加速后面的过程（或使用科学上网工具）。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm config set registry https://registry.npm.taobao.org --global</span><br><span class="line">npm config set disturl https://npm.taobao.org/dist --global</span><br></pre></td></tr></table></figure>
<h3 id="安装-hexo"><a class="markdownIt-Anchor" href="#安装-hexo"></a> 安装 <strong>hexo</strong></h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo npm install -g hexo-cli</span><br></pre></td></tr></table></figure>
<h3 id="配置环境"><a class="markdownIt-Anchor" href="#配置环境"></a> 配置环境</h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">hexo init</span><br><span class="line">npm install</span><br><span class="line">hexo g</span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>此时打开: <a href="http://localhost:4000" target="_blank" rel="noopener">http://localhost:4000</a> 即可看到效果。</p>
<h3 id="hexo-常用的命令"><a class="markdownIt-Anchor" href="#hexo-常用的命令"></a> <strong>hexo</strong> 常用的命令</h3>
<ul>
<li>$ <code>hexo g</code> 完整命令为 <strong>hexo generate</strong>，用于生成静态文件。</li>
<li>$ <code>hexo s</code> 完整命令为 <strong>hexo server</strong>，用于启动服务器，主要用来本地预览。</li>
<li>$ <code>hexo d</code> 完整命令为 <strong>hexo deploy</strong>，用于将本地文件发布到github上。</li>
<li>$ <code>hexo n</code> 完整命令为 <strong>hexo new</strong>，用于新建一篇文章。</li>
</ul>
<h2 id="部署github仓库"><a class="markdownIt-Anchor" href="#部署github仓库"></a> 部署Github仓库</h2>
<ul>
<li>
<p>新建仓库 命名为: <strong><a href="http://xn--eqr924avxo.github.io" target="_blank" rel="noopener">用户名.github.io</a></strong></p>
</li>
<li>
<p>cd 博客文件夹中, <strong><code>vim _config.yml</code></strong></p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">deploy:</span></span><br><span class="line"><span class="attr">  type:</span> <span class="string">git</span></span><br><span class="line"><span class="attr">  repository:</span> <span class="string">git@github.com:wzx3/wzx3.github.io.git</span></span><br><span class="line"><span class="attr">  branch:</span> <span class="string">master</span></span><br></pre></td></tr></table></figure>
</li>
<li>
<p>执行命令</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo generate</span><br><span class="line">hexo deploy            // 或者：hexo d</span><br></pre></td></tr></table></figure>
</li>
<li>
<p>若执行命令<code>hexo deploy</code>报错：<code>ERROR Deployer not found: git</code>，则执行如下命令来安装<code>hexo-deployer-git</code>：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure>
<p>再次执行上步命令。</p>
</li>
<li>
<p>效果</p>
<p>博客地址: <a href="https://wzx3.github.io" target="_blank" rel="noopener">https://wzx3.github.io</a></p>
</li>
</ul>
<h2 id="博客主题配置"><a class="markdownIt-Anchor" href="#博客主题配置"></a> 博客主题配置</h2>
<p>可以到<a href="https://hexo.io/themes/" target="_blank" rel="noopener">Hexo官网主题页</a>去搜寻自己喜欢的theme, 推荐使用 <a href="https://www.haomwei.com/technology/maupassant-hexo.html" target="_blank" rel="noopener">屠夫9441的博客主题</a>。</p>
<p>以下为本人的<code>maupassant</code>主题简单设置, 仅供参考。</p>
<h3 id="在博客目录下-拉取主题git"><a class="markdownIt-Anchor" href="#在博客目录下-拉取主题git"></a> 在博客目录下, 拉取主题git</h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone git@github.com:wzx3/maupassant-hexo.git themes/maupassant</span><br></pre></td></tr></table></figure>
<h3 id="修改主题名"><a class="markdownIt-Anchor" href="#修改主题名"></a> 修改主题名</h3>
<p>cd 博客文件夹中, <strong>vim _config.yml</strong></p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">theme:</span> <span class="string">maupassant</span></span><br></pre></td></tr></table></figure>
<h3 id="主题生效"><a class="markdownIt-Anchor" href="#主题生效"></a> 主题生效</h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean   //清除缓存文件 (db.json) 和已生成的静态文件 (public)</span><br><span class="line">hexo g       //生成缓存和静态文件</span><br><span class="line">hexo d       //重新部署到服务器</span><br></pre></td></tr></table></figure>
<p>每次修改<code>_config.yml</code>，都要执行上面3个命令。</p>
<h3 id="maupassant-hexo-自定义配置"><a class="markdownIt-Anchor" href="#maupassant-hexo-自定义配置"></a> maupassant-hexo 自定义配置</h3>
<p>进入主题目录, 编辑配置文件: <code>vim themes/maupassant/_config.yml</code></p>
<ul>
<li>
<p>Disqus评论相关参数</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">disqus:</span> <span class="string">wangzhuxing</span> <span class="comment">## Your disqus_shortname, e.g. username</span></span><br></pre></td></tr></table></figure>
<p>在文章的 <code>front-matter</code> 中添加 <code>comments: false</code> 即可关闭, 默认开启。</p>
</li>
<li>
<p>站内搜索</p>
<ul>
<li>
<p>方式一: 使用<code>self_search</code></p>
<p>这种方式我自己本地可以进行站内搜索, 部署推送到github上无法搜索, 很奇怪。</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">google_search:</span> <span class="literal">false</span> <span class="comment">## Use Google search, true/false.</span></span><br><span class="line"><span class="attr">self_search:</span> <span class="literal">true</span> <span class="comment">## Use a jQuery-based local search engine, true/false.</span></span><br></pre></td></tr></table></figure>
<p>关闭谷歌搜索, 开启站内搜索。</p>
<p>需安装 <code>hexo-generator-searchdb</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-generator-searchdb  --save</span><br></pre></td></tr></table></figure>
</li>
<li>
<p>方式二: 使用<code>swiftype</code></p>
<p>这种方式是直接由<strong>swiftype</strong>爬虫抓取github.io上的页面内容搜索得到的。</p>
<ul>
<li>
<p>登录<strong>Swiftype</strong>官网, 注册(可直接用谷歌账号登录)。</p>
</li>
<li>
<p>创建搜索引擎</p>
<p><img src="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnjnv8wuj21ci0oijx5.jpg" alt="CREATE A NEW ENGINE"></p>
</li>
<li>
<p>输入你的<strong><a href="http://github.io" target="_blank" rel="noopener">github.io</a></strong>, 记得末尾要带<code>/</code>, 然后取个名字, 创建成功。</p>
<p><img src="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnn0grfij21dc0m00x2.jpg" alt="输入github.io"></p>
</li>
<li>
<p>安装搜索引擎</p>
<p><img src="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnrp3fz0j21du13k7e6.jpg" alt="安装搜索引擎"></p>
<p>底下会提示: <strong>网站搜索爬虫正在爬虫你的网页, 在完成之前无法进行样式配置和站点搜索。</strong></p>
<p><img src="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnse6mr5j212c02cmx8.jpg" alt></p>
<p>大约等个十几分钟左右, 底下提示栏消失, 这时候<strong>Install Search</strong>页面会多出一段<code>js</code>代码:</p>
<p><img src="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnvwsv5rj21dc0xcjze.jpg" alt></p>
<p><code>swiftype_key</code>就在这段代码的底下:</p>
<p><img src="http://ww1.sinaimg.cn/large/929ea2a1gy1g0cnxgf5j5j21cw0a6mz4.jpg" alt></p>
<p>将其复制到主题配置设置</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">swiftype:</span>  <span class="comment">## Your swiftype_key, e.g. m7b11ZrsT8Me7gzApciT</span></span><br></pre></td></tr></table></figure>
</li>
<li>
<p>重新部署并推送远端即可完成站内搜索配置</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo g &amp;&amp; hexo d</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>添加分享按钮</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">shareto:</span> <span class="literal">true</span> <span class="comment">## If you want to use the share button please set the value to true, and you must have hexo-helper-qrcode installed.</span></span><br></pre></td></tr></table></figure>
<p>需安装 <code>hexo-helper-qrcode</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-helper-qrcode  --save</span><br></pre></td></tr></table></figure>
</li>
<li>
<p>是否开启页面访问计数</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">busuanzi:</span> <span class="literal">true</span> <span class="comment">## If you want to use Busuanzi page views please set the value to true.</span></span><br></pre></td></tr></table></figure>
</li>
<li>
<p>是否开启文章字数统计、阅读时长显示</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">wordcount:</span> <span class="literal">true</span> <span class="comment">## If you want to display the word counter and the reading time expected to spend of each post please set the value to true, and you must have hexo-wordcount installed.</span></span><br></pre></td></tr></table></figure>
</li>
<li>
<p>是否开启捐赠按钮</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">donate:</span></span><br><span class="line"><span class="attr">  enable:</span> <span class="literal">true</span> <span class="comment">## If you want to display the donate button after each post, please set the value to true and fill the following items on your need. You can also enable donate button in a page by adding a "donate: true" item to the front-matter.</span></span><br><span class="line"><span class="attr">  alipay_qr:</span> <span class="string">/img/alipay.jpg</span> <span class="comment">## Path of Alipay QRcode image, e.g. /img/AliPayQR.png</span></span><br><span class="line"><span class="attr">  wechat_qr:</span> <span class="string">/img/wechatpay.jpg</span> <span class="comment">## Path of Wechat QRcode image, e.g. /img/WeChatQR.png</span></span><br></pre></td></tr></table></figure>
</li>
<li>
<p>是否在末尾显示原文作者</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">post_copyright:</span></span><br><span class="line"><span class="attr">  enable:</span> <span class="literal">true</span> <span class="comment">## If you want to display the copyright info after each post, please set the value to true and fill the following items on your need.</span></span><br><span class="line"><span class="attr">  author:</span> <span class="string">王竹兴</span> <span class="comment">## Your author name, e.g. tufu9441</span></span><br><span class="line"><span class="attr">  copyright_text:</span> <span class="string">本文为博主原创文章，转载请附上博文链接！</span> <span class="comment">## Your copyright text, e.g. The author owns the copyright, please indicate the source reproduced.</span></span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="迁移博客部署"><a class="markdownIt-Anchor" href="#迁移博客部署"></a> 迁移博客部署</h2>
<ul>
<li>博客部署的<strong>github仓库</strong>(如我的是 <a href="https://github.com/wzx3/wzx3.github.io" target="_blank" rel="noopener">https://github.com/wzx3/wzx3.github.io</a> ), 新建分支: <code>hexo-deploy</code></li>
<li>将仓库 <strong>clone</strong> 到本地, 除 <code>.git</code> 文件夹外, 其余的全部删除, 并推送到远端。</li>
<li>将<code>.git</code>文件夹移动到博客目录下, 推送hexo的部署内容。</li>
<li>之后重新部署后, 同步推送该分支, 保持最新。</li>
<li>新电脑上, 同样先安装<code>npm</code>和<code>hexo</code>, 再将上述分支<strong>clone</strong>到本地, 执行 <code>npm install</code> 即可快速完成部署。</li>
</ul>
<h2 id="博文撰写相关"><a class="markdownIt-Anchor" href="#博文撰写相关"></a> 博文撰写相关</h2>
<h3 id="front-matter"><a class="markdownIt-Anchor" href="#front-matter"></a> Front-matter</h3>
<p>Front-matter 是文件最上方以 <code>---</code> 分隔的区域，用于指定个别文件的变量。</p>
<p>举例来说：</p>
<figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: Hello World</span><br><span class="line">date: 2013/7/13 20:46:25</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
<p>以下是预先定义的参数，您可在模板中使用这些参数值并加以利用。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>描述</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>layout</code></td>
<td>布局</td>
<td></td>
</tr>
<tr>
<td><code>title</code></td>
<td>标题</td>
<td></td>
</tr>
<tr>
<td><code>date</code></td>
<td>建立日期</td>
<td>文件建立日期</td>
</tr>
<tr>
<td><code>updated</code></td>
<td>更新日期</td>
<td>文件更新日期</td>
</tr>
<tr>
<td><code>comments</code></td>
<td>开启文章的评论功能</td>
<td>true</td>
</tr>
<tr>
<td><code>tags</code></td>
<td>标签（不适用于分页）</td>
<td></td>
</tr>
<tr>
<td><code>categories</code></td>
<td>分类（不适用于分页）</td>
<td></td>
</tr>
<tr>
<td><code>permalink</code></td>
<td>覆盖文章网址</td>
<td></td>
</tr>
</tbody>
</table>
<ul>
<li>
<p>参考资料</p>
<p><a href="https://www.toutiao.com/i6629166603839734286/" target="_blank" rel="noopener">Hexo+Github+Coding免费搭建个人静态博客</a></p>
<p><a href="https://www.jianshu.com/p/5014133ba61a" target="_blank" rel="noopener">使用Gitee+Hexo搭建个人博客</a></p>
</li>
</ul>

      
    </div>
    <div class="article-footer">
      <!-- <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="http://zhulao.gitee.io/blog/2019/02/19/Hexo-Github免费搭建个人静态博客/" title="Hexo+Github免费搭建个人静态博客" target="_blank" rel="external">http://zhulao.gitee.io/blog/2019/02/19/Hexo-Github免费搭建个人静态博客/</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://github.com/wzx3" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/blog/images/avatar.jpeg" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://github.com/wzx3" target="_blank"><span class="text-dark">王竹兴</span><small class="ml-1x"></small></a></h3>
        <div></div>
      </div>
    </figure>
  </div>
</div>
 -->

    </div>
  </article>
  
    
  <section id="comments">
  	
  </section>


  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/blog/2019/02/20/Git基础使用方法/" title="Git基础使用方法"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;上一篇</span></a>
    </li>
    
    
    
    <li class="toggle-toc">
      <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false" title="文章目录" role="button">
        <span>[&nbsp;</span><span>文章目录</span>
        <i class="text-collapsed icon icon-anchor"></i>
        <i class="text-in icon icon-close"></i>
        <span>]</span>
      </a>
    </li>
    
  </ul>
  
  
  
  <div class="bar-right">
    
    <div class="share-component" data-sites="weibo,qq,wechat,facebook,twitter" data-mobile-sites="weibo,qq,qzone"></div>
    
  </div>
  </div>
</nav>
  


</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/wzx3" target="_blank" title="Github" data-toggle="tooltip" data-placement="top"><i class="icon icon-github"></i></a></li>
        
        <li><a href="/blog/atom.xml" target="_blank" title="Rss" data-toggle="tooltip" data-placement="top"><i class="icon icon-rss"></i></a></li>
        
    </ul>

    <div class="copyright">
    	
        <div class="publishby">
        	Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>.
        </div>
    </div>
</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>
<script src="/blog/js/plugin.min.js"></script>
<script src="/blog/js/application.js"></script>

    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/blog/',
        CONTENT_URL: '/blog/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/blog/js/insight.js"></script>





   
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





   






</body>
</html>